package com.jic.interaction.cardCouponPlatform.controller;

import com.jic.interaction.cardCouponPlatform.common.utils.BeanUtils;
import com.jic.interaction.cardCouponPlatform.common.utils.RestResult;
import com.jic.interaction.cardCouponPlatform.model.entity.CardCouponPlatform;
import com.jic.interaction.cardCouponPlatform.model.entity.OrderCouponPlatform;
import com.jic.interaction.cardCouponPlatform.model.vo.request.CardCouponPlatformRequest;
import com.jic.interaction.cardCouponPlatform.model.vo.request.OrderCouponPlatformRequest;
import com.jic.interaction.cardCouponPlatform.service.CardCouponPlatformService;
import com.jic.weamop.api.WeAMOPApi;
import com.jic.weamop.request.MessageRequestApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther YGH
 * @DATE 2020/11/11/13:54
 */
@RestController
@RequestMapping("/card")
@Slf4j
//TODO 充值账号类型	remarks  用什么区分？
@Api(value = "卡券平台", tags = "卡券平台", description = "CardCouponPlatformController")
public class CardCouponPlatformController {

    @Autowired
    CardCouponPlatformService cardCouponPlatformService;

    @Autowired
    WeAMOPApi weAMOPApi;

        /*
         * @Author chengpunan
         *@Package com.jic.interaction.cardCouponPlatform.controller
         *ClassName CardCouponPlatformController
         * @Description  //TODO
         * @Date 16:48 2020/11/11
         * @Param CardCouponPlatformRequest 采购商信息
         * @return  订单编码
         * @Version:1.0
         **/
        @ApiOperation(value = "采购商下单", notes = "采购商下单。")
        @PostMapping("/addCardCouponPlatform")
        public RestResult<?> addCardCouponPlatform(@RequestBody CardCouponPlatformRequest cardCouponPlatformRequest) throws Exception {
            CardCouponPlatform cardCouponPlatform=new CardCouponPlatform();
            BeanUtils.Copy(cardCouponPlatformRequest,cardCouponPlatform);
            String param = cardCouponPlatformService.addPlaceAnOrder(cardCouponPlatform);
            return RestResult.success("9999",param);
        }

    /*
     * @Author chengpunan
     *@Package com.jic.interaction.cardCouponPlatform.controller
     *ClassName CardCouponPlatformController
     * @Description  //TODO
     * @Date 16:53 2020/11/11
     * @Param CardCouponPlatformRequest 采购商信息
     * @return 订单信息
     * @Version:1.0
     **/
    @ApiOperation(value = "订单信息", notes = "订单信息。")
    @PostMapping("/getCardCouponPlatform")
    public RestResult<?> getCardCouponPlatform(@RequestBody OrderCouponPlatformRequest cardCouponPlatformRequest) throws Exception {
        OrderCouponPlatform platform=new OrderCouponPlatform();
        BeanUtils.Copy(cardCouponPlatformRequest,platform);
        String placeAnOrder = cardCouponPlatformService.getPlaceAnOrder(platform);
        return RestResult.success("9999",placeAnOrder);
    }


    /*
     * @Author chengpunan
     *@Package com.jic.interaction.cardCouponPlatform.controller
     *ClassName CardCouponPlatformController
     * @Description  //TODO
     * @Date 16:53 2020/11/11
     * @Param CardCouponPlatformRequest 采购商信息
     * @return 订单信息
     * @Version:1.0
     **/
    @ApiOperation(value = "订单信息", notes = "订单信息。")
    @PostMapping("/test")
    public RestResult<?> test(@RequestBody MessageRequestApi messageRequestApi) throws Exception {
        String placeAnOrder = weAMOPApi.test(messageRequestApi);
        return RestResult.success("9999",placeAnOrder);
    }

}
